package com.ssm.service.impl;

import com.ssm.dao.ClassesDao;
import com.ssm.dao.StudentDao;
import com.ssm.pojo.Classes;
import com.ssm.pojo.Student;
import com.ssm.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service("studentService")
public class StudentServiceImpl implements StudentService {

    @Autowired
    private ClassesDao classesDao;
    @Autowired
    private StudentDao studentDao;
    @Override
    public Map<String, Object> query(Student student) throws Exception {

        Map<String, Object> studentMap=new HashMap<>();
        List list= studentDao.query(student);
        studentMap.put("data",list);
        studentMap.put("code","200");
        studentMap.put("massage","success");
        return studentMap;
    }

    @Override
    public Map<String, Object> addClass(Student student) throws Exception {
        Map<String, Object> studentMap=new HashMap<>();
        int i= studentDao.addStudent(student);
        if(i>0){
            studentMap.put("data",i);
            studentMap.put("code","200");
            studentMap.put("massage","success");
        }else{
            studentMap.put("data",i);
            studentMap.put("code","000");
            studentMap.put("massage","fail");
        }
        return studentMap;
    }
}
